package ms.maplestory.boot.packets.universal;

import ms.maplestory.boot.client.character.CharStat;
import ms.maplestory.boot.connection.OutPacket;
import ms.maplestory.boot.constants.JobConstants;

public class CharacterStat {

    public static OutPacket encode(OutPacket out, CharStat charStat) {
        out.encodeInt(charStat.getCharId());
        out.encodeString(charStat.getName(), 13);
        out.encodeByte(charStat.getGender());
        out.encodeByte(charStat.getSkin());
        out.encodeInt(charStat.getFace());
        out.encodeInt(charStat.getHair());
        for (int i = 0; i < 3; i++) { // PetLockerSN
            out.encodeLong(0);
        }
        out.encodeByte(charStat.getLevel());
        out.encodeShort(charStat.getJob());
        out.encodeShort(charStat.getStr());
        out.encodeShort(charStat.getDex());
        out.encodeShort(charStat.getInt_());
        out.encodeShort(charStat.getLuk());
        out.encodeInt(charStat.getHp());
        out.encodeInt(charStat.getMaxHp());
        out.encodeInt(charStat.getMp());
        out.encodeInt(charStat.getMaxMp());
        out.encodeShort(charStat.getAp());
        if (JobConstants.isExtendSpJob(charStat.getJob())) {
            ExtendSP.encode(out, charStat.getExtendSP());
        } else {
            out.encodeShort(charStat.getSp());
        }
        out.encodeInt(charStat.getExp());
        out.encodeShort(charStat.getPop());
        out.encodeInt(charStat.getTempExp());
        out.encodeInt(charStat.getPosMap());
        out.encodeByte(charStat.getPortal());
        out.encodeInt(charStat.getPlayTime());
        out.encodeShort(charStat.getSubJob());
        return out;
    }

}
